<template>
  <div>
    <van-nav-bar
    :title="replyData.reply_count ? replyData.reply_count + '条回复' : '暂无回复'"
    >
    <van-icon slot="left" name="cross"  @click="$emit('replyclose')"/>
    </van-nav-bar>

    <div class="replyContainer">

    <comment-item :comment="replyData"></comment-item>

    <van-cell title="全部回复"/>

    <comment-list type="c" :source="replyData.com_id + ''" :list="eventBusData"></comment-list>

    </div>

    <div class="post-warp">
      <van-button @click="showComment = true" round>评论</van-button>
    </div>
    <van-popup v-model="showComment" position="bottom">
      <post-conment @post_success="onPostSuccess" :artId="$route.params.articleId"  :target="replyData.com_id + ''"></post-conment>
    </van-popup>
  </div>
</template>

<script>
import CommentItem from '@/components/comment-item'
import CommentList from '@/components/article-comment'
import PostConment from './post-comment'

export default {
  props: {
    replyData: {
      type: Object,
      required: true
    }
  },
  data () {
    return {
      showComment: false,
      eventBusData: []
    }
  },
  components: {
    CommentItem,
    CommentList,
    PostConment
  },

  created () {

  },

  methods: {
    onPostSuccess (data) {
      this.showComment = false
      console.log(data)
      this.eventBusData.unshift(data)
    }
  }
}
</script>

<style scoped lang='less'>
.post-warp {
  background: #008c8c;
  width: 100%;
  height: 100px;
  position: fixed;
  bottom: 0;
  border-top: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  .van-button {
    width: 640px;
    height: 80px;
  }
}
.replyContainer {
  width: 100%;
  position: absolute;
  top: 102px;
  overflow: scroll;
  bottom: 102px;
}
</style>
